package edu.kaist.cs408.pof.backend.provider;

import org.bson.types.ObjectId;
import org.codehaus.jackson.Version;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.module.SimpleModule;
import org.jboss.resteasy.plugins.providers.jackson.ResteasyJacksonProvider;

import javax.ws.rs.Consumes;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.ext.Provider;

/**
 * Created with IntelliJ IDEA.
 * User: duyleekun
 * Date: 5/14/12
 * Time: 7:00 PM
 * To change this template use File | Settings | File Templates.
 */
@Provider
@Consumes({MediaType.APPLICATION_JSON, "text/json"})
@Produces({MediaType.APPLICATION_JSON, "text/json"})
public class JacksonConfigurator extends ResteasyJacksonProvider {
	public JacksonConfigurator() {
		super();

		ObjectMapper mapper = _mapperConfig.getDefaultMapper();


		SimpleModule myModule = new SimpleModule("MyModule", new Version(1, 0, 0, null));
		myModule.addSerializer(ObjectId.class, new ObjectIdSerializer());

		mapper.registerModule(myModule);

	}
}
